package com.bvbot.core.session;

import java.math.BigDecimal;

public class SaleResponse extends BvResponse {

	private Integer gramsSold;

	public SaleResponse(String content) {
		super(content);
	}

	public String getSummary() {
		StringBuilder sb = new StringBuilder();
		sb.append("" + getGramsSold() + " grams have been sold.");
		return sb.toString();
	}

	public Integer getGramsSold() {
		if (gramsSold == null) {
			String qtyMatchedString = "quantityMatched";
			String qtyMatched = extractAttributValue(qtyMatchedString,
					getContent());
			if (qtyMatched != null) {
				BigDecimal tmp = getValueMultipliedBy1000(qtyMatched);
				if (tmp != null) {
					gramsSold = tmp.intValueExact();
				}
			}
		}
		return gramsSold;
	}

}
